<?php
class Frmcreator_Model_Form extends Core_Model_Item_Abstract
{
    protected $_searchTriggers = false;
    protected $_statusLabel = array('No', 'Yes');
     
    const INACTIVE = 0;
    const ACTIVE = 1;   
    

    public function getStatusLabel()
    {
        return $this->_statusLabel[$this->status];
    }

    public function _delete(){
        //Clean all data related to form (elements)
    }
    
    public function getHref($params = array())
    {
        $params = array_merge(array(
          'route' => 'frmcreator_view',
          'reset' => true,
          'action' => $this->url,
        ), $params);
        $route = $params['route'];
        $reset = $params['reset'];
        unset($params['route']);
        unset($params['reset']);
        return Zend_Controller_Front::getInstance()->getRouter()
          ->assemble($params, $route, $reset);
    }
    
    public function getElements(){
        $table = Engine_Api::_()->getDbtable('elements', 'frmcreator');
        $select = $table->select();
        $select->where('form_id = ?', $this->form_id);
        $select->order('order');
        
        $elements = $table->fetchAll($select);
        
        return $elements;
    }
}
